package com.bk.cyxf.log;

import jt.classic.system.ISystemException;
import jt.classic.system.SimpleManager;
import jt.classic.system.user.IUser;

import org.limp.basework.SimpleBean4Table;
import org.limp.basework.impl.SimpleBean4TableImpl;
import org.limp.basework.tools.BaseworkUtil;

import org.limp.mine.DateTrimmer;

import java.sql.Connection;

/**
 * 信访办理日志管理器
 * 
 * @author Mido
 *
 */
public class LogManager extends SimpleManager {
    public LogManager(Connection conn) {
        super(conn);
    }

    /**
     * 日志记录
     * @param user 用户实例
     * @param id 信访对象ID
     * @param type 信访对象类型
     * @param opera 操作类型(see element 'xf_logtype' in wordbook.xml)
     * @param memo 操作内容
     * @throws ISystemException
     */
    public void log(IUser user, String id, String type, String opera,
        String memo) throws ISystemException {
        SimpleBean4Table sbt = new SimpleBean4TableImpl("APP_XFLOG");

        sbt.getResource().put("L_DATE", DateTrimmer.getYMDHMS());
        sbt.getResource().put("XFID", id);
        sbt.getResource().put("XF_TYPE", type);
        sbt.getResource().put("L_USERID", user.id());
        sbt.getResource().put("L_USERNAME", user.iname());
        sbt.getResource().put("L_GROUPID", user.igroup().id());
        sbt.getResource().put("L_GROUPNAME", user.igroup().iname());
        sbt.getResource().put("L_TYPE", opera);
        sbt.getResource().put("L_MEMO", memo);

        BaseworkUtil util = new BaseworkUtil();

        try {
            util.manualSave1(sbt, this.conn);
        } catch (Exception ex) {
            throw new ISystemException(ex);
        }
    }
}
